<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <link rel="stylesheet" type="text/css" href="/static/Admin/plugins/colorpicker/colorpicker.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/custom-plugins/wizard/wizard.css" media="screen">
    
    <!-- Required Stylesheets -->
    <link rel="stylesheet" type="text/css" href="/static/Admin/bootstrap/css/bootstrap.min.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/fonts/ptsans/stylesheet.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/fonts/icomoon/style.css" media="screen">
    
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/mws-style.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/icons/icol16.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/icons/icol32.css" media="screen">
    
    <!-- Demo Stylesheet -->
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/demo.css" media="screen">
    
    <!-- jQuery-UI Stylesheet -->
    <link rel="stylesheet" type="text/css" href="/static/Admin/jui/css/jquery.ui.all.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/jui/jquery-ui.custom.css" media="screen">
    
    <!-- Theme Stylesheet -->
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/mws-theme.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/themer.css" media="screen">
</head>
<body>
   
        <div class="mws-panel grid_8">
            <div class="mws-panel-header" style="height: 49px">
                <span>
                    <i class="icon-table"></i> 优惠券列表</span>
            </div>

            <div class="mws-panel-body no-padding">
                <div id="DataTables_Table_1_wrapper" class="dataTables_wrapper" role="grid">
                       
                        <div id="DataTables_Table_1_length" class="dataTables_length">
                            <a href="/coupon/CouponAdd" class="btn btn-info">添加优惠券</a>
                        </div>

                    <div class="dataTables_filter" id="DataTables_Table_1_filter" style="height: 50px;">
                        <!-- <label>
                            <input type="search" aria-controls="DataTables_Table_1" >
                        </label> -->
                    </div>

                    <table class="mws-datatable-fn mws-table dataTable" id="DataTables_Table_1" aria-describedby="DataTables_Table_1_info">
                        <thead>
                            <tr role="row">
                                <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1"
                                    colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending"
                                    style="width: 248px;">ID</th>
                                <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                    rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending" style="width: 325px;">要求金额</th>
                                <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                    rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="width: 298px;">满减金额</th>
                                <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending"
                                    style="width: 298px;">有效时间</th>
                                <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending"
                                    style="width: 298px;">是否可领取</th>
                                <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending"
                                    style="width: 298px;">操作</th>


                            </tr>
                        </thead>
        
                        <tbody>
                            {foreach name="list" item="vo"}
                            <tr class="gradeA odd">
                                <td class="">{$vo.coupon_id}</td>
                                <td class="">{$vo.amount}</td>
                                <td class="">{$vo.discount}</td>
                                <td class="">{$vo.expire}</td>
                                <td class="">
                                    {switch name="vo.available"} {case value="1" }
                                    <a href="javascript:;" class="btn btn-success ChangeStatus" name="{$vo.coupon_id}" value="0">当前状态可用</a>
                                    {/case} {case value="0"}
                                    <a href="javascript:;" class="btn btn-danger ChangeStatus" name="{$vo.coupon_id}" value="1">当前状态不可用</a>
                                    {/case} {/switch}
                                </td>
                                
                                <td class="">
                                    <!-- <a href="/goods/EditGoods/id/{$vo.coupon_id}" class="btn btn-info ">修改信息</a> -->
                                    <a href="javascript:;" class="btn btn-danger del" name="{$vo.coupon_id}" >删除</a>
                                </td>
                                      
                            </tr>
                            {/foreach}
                        </tbody>
                    </table>
                    <div class="dataTables_info" id="DataTables_Table_1_info">总数据条数 {$coupon_amount}</div>
                    <div class="" id="DataTables_Table_1_paginate" style="text-align: center">
                        {$page} 
                    </div>

                </div>
            </div>
        </div> 


        
        
        
</body>
<!-- JavaScript Plugins -->
<script src="/static/Admin/js/libs/jquery-1.8.3.min.js"></script>
<script src="/static/Admin/js/libs/jquery.mousewheel.min.js"></script>
<script src="/static/Admin/js/libs/jquery.placeholder.min.js"></script>
<script src="/static/Admin/custom-plugins/fileinput.js"></script>

<!-- jQuery-UI Dependent Scripts -->
<script src="/static/Admin/jui/js/jquery-ui-1.9.2.min.js"></script>
<script src="/static/Admin/jui/jquery-ui.custom.min.js"></script>
<script src="/static/Admin/jui/js/jquery.ui.touch-punch.js"></script>

<!-- Plugin Scripts -->
<script src="/static/Admin/plugins/datatables/jquery.dataTables.min.js"></script>
<!--[if lt IE 9]>
        <script src="js/libs/excanvas.min.js"></script>
        <![endif]-->
<script src="/static/Admin/plugins/flot/jquery.flot.min.js"></script>
<script src="/static/Admin/plugins/flot/plugins/jquery.flot.tooltip.min.js"></script>
<script src="/static/Admin/plugins/flot/plugins/jquery.flot.pie.min.js"></script>
<script src="/static/Admin/plugins/flot/plugins/jquery.flot.stack.min.js"></script>
<script src="/static/Admin/plugins/flot/plugins/jquery.flot.resize.min.js"></script>
<script src="/static/Admin/plugins/colorpicker/colorpicker-min.js"></script>
<script src="/static/Admin/plugins/validate/jquery.validate-min.js"></script>
<script src="/static/Admin/custom-plugins/wizard/wizard.min.js"></script>

<!-- Core Script -->
<script src="/static/Admin/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/Admin/js/core/mws.js"></script>

<!-- Themer Script (Remove if not needed) -->
<script src="/static/Admin/js/core/themer.js"></script>

<!-- Demo Scripts (remove if not needed) -->
<script src="/static/Admin/js/demo/demo.dashboard.js"></script>

<!-- ajax修改上架状态 -->
<script>
    $('.ChangeStatus').on('click',function () {
        var val=$(this).attr('value');
        var id=$(this).attr('name');
        me=$(this);
        $.ajax({
            url:'/Coupon/AjaxWithdrawGoods',
            type:'post',
            data: {'coupon_id':id,'available':val},
            success: function (data) {
                if(data){
                    if(val == 1){
                        me.removeClass('btn-danger').addClass('btn-success').attr('value','0').html('当前状态可用');
                    }else if(val == 0){
                        me.removeClass('btn-success').addClass('btn-danger').attr('value', '1').html('当前状态不可用');
                    }
                }
            }
        })
    })

    // 删除商品

    $('.del').on('click',function () {

        var sure = window.confirm('确定删除');
        var id = $(this).attr('name');
        me = $(this);
        if (sure) {
            $.post('/coupon/CouponDel', { "id": id }, function (data) {
                if (data == 1) {
                    me.parents('tr').remove();

                } else {
                    alert('操作失败，请重新尝试');
                }
            })
        }
    })
    
    

</script>

</html>